package com.qq.BFMRSE.runnable;

import java.io.File;

import com.qq.BFMRSE.encrypt.desEncrypt;
import com.qq.BFMRSE.encrypt.encryotHelper;
import com.qq.BFMRSE.requestModule.upLoadFileModule;
import com.qq.BFMRSE.requestModule.upLoadModule;
import com.qq.BFMRSE.serialize.objectSerializeUtil;
import com.qq.BFMRSE.util.BFConstants;

public class uploadRunnable implements Runnable{
	private String url;
	private String userName;
	private int upType;//上传的文件类型，1位加密文档，2位加密索引树，3为加密索引
	private Object content;
	private String keyPath;
	public Object getContent(){
		return content;
	}
	public void setContent(Object content){
		this.content=content;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public int getUpType(){
		return upType;
	}
	public void setUpType(int upType){
		this.upType=upType;
	}
	public uploadRunnable(String url,Object content,String userName,int upType){
		this.url=url;
		this.userName=userName;
		this.upType=upType;
		this.content=content;
		this.keyPath="";
	}
	public uploadRunnable(String url,Object content,String userName,int upType,String keyPath){
		this.url=url;
		this.userName=userName;
		this.upType=upType;
		this.content=content;
		this.keyPath=keyPath;
	}
	public uploadRunnable(){}
	@Override
	public void run() {
		// TODO Auto-generated method stub
		if(upType==BFConstants.UPENCRYPTFILE){
			//上传加密文件
			desEncrypt desEn=new desEncrypt(keyPath);
			desEn.encryptAllFiles((String)content, BFConstants.ENCRYPTFILETEMPDIR);
			upLoadFileModule.upLoadFiles(url, BFConstants.ENCRYPTFILETEMPDIR, userName);
			upLoadFileModule.deleteDir(new File(BFConstants.ENCRYPTFILETEMPDIR));
			
		}else if(upType==BFConstants.UPENCRYPTTREE){
			//上传加密索引树
			upLoadModule.upLoadAllFileInfo(url, content, userName);
			
		}else if(upType==BFConstants.UPENCRYPTINDEX){
			//上传加密索引
			upLoadModule.upLoadEnIndexInfo(url, content, userName);
			
		}
	}

}
